#ifndef T1_ISO_H
#define T1_ISO_H

#include "iodef.h"

typedef struct {
        __IO uint32_t SCIMODHW;
        __IO uint32_t SCIMODSW;
        __IO uint32_t SCICTRL;
        __IO uint32_t SCISTAT;
        __IO uint32_t SCIINTIO1;
        __IO uint32_t SCIINTIO2;
        __IO uint32_t EDCCTRL;
        __IO uint32_t WTCTRL;
        __IO uint32_t SCIBUFHW;
        __IO uint32_t SCIBUFSW;
        __IO uint32_t ETUDATA;
        __IO uint32_t BGTDATA;
        __IO uint32_t CWTDATA;
        __IO uint32_t EDCDATA;
        __IO uint32_t SCIMODSW2;
        __IO uint32_t SCIBUFSW2;
        __IO uint32_t SCIINTRST;
}icc_reg_t;

/* SCIMODHW */
#define ICC_outtyp _BIT(2)
#define ICC_dirc   _BIT(1)
#define ICC_tmode  _BIT(0)

/* SCICTRL */
#define ICC_TX_FIFO_CLR        _BIT(5)
#define ICC_RX_FIFO_CLR        _BIT(4)

/* SCISTAT */
#define ICC_CWT_FLAG           _BIT(7)
#define ICC_BGT_FLAG           _BIT(6)
#define ICC_TX_ERROR           _BIT(5)
#define ICC_TX_FIFO_FULL       _BIT(4)
#define ICC_TX_FIFO_NOT_EMPTY  _BIT(3)
#define ICC_RX_ERROR           _BIT(2)
#define ICC_RX_FIFO_FULL       _BIT(1)
#define ICC_RX_FIFO_NOT_EMPTY  _BIT(0)

/* SCIINTIO1 */
#define ICC_TX_INT             _BIT(2)
#define ICC_RX_INT             _BIT(1)
#define ICC_IO_INT             _BIT(0)

#define ISO0 ((icc_reg_t*)T1_78160_BASE)
#define ISO1 ((icc_reg_t*)T1_78161_BASE)
#define ISO2 ((icc_reg_t*)T1_78162_BASE)

typedef enum {
	IP0 = 0,
	IP1 = 1,
	IP2 = 2,
}IPNum_t;

#define ERR_ATR_START_TIMEOUT   -1001
#define ERR_ATR_BYTE_TIMEOUT    -1002
#define ERR_ATR_TIMEOUT         -1003
#define ERR_ATR_TS              -1004
#define ERR_ATR_PARITY          -1005
#define ERR_ATR_TCK_T0          -1006
#define ERR_ATR_TCK_T1          -1007
#define ERR_INVALID_SW          -1008
#define ERR_SEND_PARITY         -1009
#define ERR_RECV_TIMEOUT        -1010
#define ERR_RECV_PARITY         -1011
#define ERR_RECV_LRC            -1012
#define ERR_INVALID_NAD         -1013
#define ERR_INVALID_LEN         -1014
#define ERR_ABORT_T1            -1015
#define ERR_SETIFSD_FAILURE     -1016
#define ERR_INVALID_INF         -1017
#define ERR_MAX_RETRIED         -1018
#define ERR_IFSD_ERROR          -1019

#endif
